﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ErrorTracking.aspx.cs" Inherits="ErrorTracking" Title="CSharpUniversity.com ASP.NET Error Tracking website - View Errors" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div>
             <br /><br />
        <asp:Label ID="lblTitle" runat="server" Text="View Errors - Application: " 
            Font-Bold="True" Font-Size="Large"></asp:Label>
        <asp:Label ID="lblApplicationName" runat="server" Text=""></asp:Label>
        <asp:Panel ID="Panel1" runat="server" GroupingText="Quick search">
            <asp:Button ID="btnDisplayRecent100" runat="server" Text="Recent 100 errors" 
                onclick="btnDisplayRecent100_Click" />
            <asp:Button ID="btnDisplayRecent500" runat="server" Text="Recent 500 errors" 
                onclick="btnDisplayRecent500_Click" />
            <br />
            <asp:Button ID="btnDisplayThisWeek" runat="server" 
                Text="All errors past 7 days" onclick="btnDisplayThisWeek_Click" />
        </asp:Panel>
        <asp:Label ID="Label15" runat="server" Text="OR" Font-Size="Large"></asp:Label>
        <asp:Panel ID="Panel2" runat="server" GroupingText="Search">
            <asp:Label ID="Label13" runat="server" Text="Error Id"></asp:Label>
            <asp:TextBox ID="txtErrorId" runat="server" MaxLength="10"></asp:TextBox>
            <asp:CustomValidator ID="ErrorIdValidator" runat="server" ErrorMessage="Error Id must be an Integer" OnServerValidate="ValidateErrorId"></asp:CustomValidator>
            <asp:Label ID="Label1" runat="server" Text="Start Date"></asp:Label>
            <asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>
            <asp:Label ID="Label2" runat="server" Text="End Date"></asp:Label>
            <asp:TextBox ID="txtEndDate" runat="server"></asp:TextBox>
            <asp:CustomValidator ID="DateValidator" runat="server" ErrorMessage="CustomValidator" OnServerValidate="ValidateStartEndDate"></asp:CustomValidator>
            <br />
            <asp:RadioButton ID="rbExactMatch" runat="server" GroupName="matchtype" 
                Text="Exact Match" Checked="True" />
            <asp:RadioButton ID="rbPartialMatch" runat="server" GroupName="matchtype" Text="Partial Match" />
            <br />
            <asp:Label ID="Label3" runat="server" Text="Error message"></asp:Label>
            <asp:TextBox ID="txtErrorMessage" runat="server"></asp:TextBox>
            <asp:Label ID="Label4" runat="server" Text="Stacktrace"></asp:Label>
            <asp:TextBox ID="txtStackTrace" runat="server"></asp:TextBox>
            <asp:Label ID="Label5" runat="server" Text="Location"></asp:Label>
            <asp:TextBox ID="txtLocation" runat="server"></asp:TextBox>
            <br />
            <asp:Label ID="Label6" runat="server" Text="ClientIP"></asp:Label>
            <asp:TextBox ID="txtClientIP" runat="server"></asp:TextBox>
            <asp:Label ID="Label7" runat="server" Text="ServerName"></asp:Label>
            <asp:TextBox ID="txtServerName" runat="server"></asp:TextBox>
            <br />
            <asp:Label ID="Label8" runat="server" Text="Custom1"></asp:Label>
            <asp:TextBox ID="txtCustom1" runat="server"></asp:TextBox>
            <asp:Label ID="Label9" runat="server" Text="Custom2"></asp:Label>
            <asp:TextBox ID="txtCustom2" runat="server"></asp:TextBox>
            <asp:Label ID="Label10" runat="server" Text="Custom3"></asp:Label>
            <asp:TextBox ID="txtCustom3" runat="server"></asp:TextBox>
            <br />
            <asp:Label ID="Label11" runat="server" Text="Custom4"></asp:Label>
            <asp:TextBox ID="txtCustom4" runat="server"></asp:TextBox>
            <asp:Label ID="Label12" runat="server" Text="Custom5"></asp:Label>
            <asp:TextBox ID="txtCustom5" runat="server"></asp:TextBox>
            <br />
            
            <br />
        <asp:Button ID="btnSearchErrors" runat="server" Text="Search" 
            onclick="btnSearchErrors_Click" />
            <asp:Label ID="lblSearchResults" runat="server" Text="" ForeColor="Red"></asp:Label>    
            <asp:Label ID="Label14" runat="server" Text="Max # records"></asp:Label>
            <asp:TextBox ID="txtMaxNumRecords" runat="server" Text="500" Width="50px" 
                MaxLength="5"></asp:TextBox>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                ErrorMessage="Max # must be an Integer" ControlToValidate="txtMaxNumRecords" 
                ValidationExpression="[0-9]{1,5}"></asp:RegularExpressionValidator>
            <asp:RadioButton ID="rbNewestFirst" runat="server" GroupName="sortorder" 
                Text="Newest first" Checked="True" />
            <asp:RadioButton ID="rbOldestFirst" runat="server" GroupName="sortorder" Text="Oldest first" />
        </asp:Panel>
        <br />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            EnableViewState="False">
            <Columns>
                <asp:BoundField DataField="error_id" HeaderText="ErrorId" />
                <asp:BoundField DataField="time_occured" HeaderText="Time" />
                <asp:BoundField DataField="error_message" HeaderText="Error" />
                <asp:BoundField DataField="stacktrace" HeaderText="Stack" />
                <asp:BoundField DataField="location" HeaderText="Location" />
                <asp:BoundField DataField="clientip" HeaderText="ClientIP" />
                <asp:BoundField DataField="servername" HeaderText="Server" />
                <asp:BoundField DataField="custom1" HeaderText="Custom1" />
                <asp:BoundField DataField="custom2" HeaderText="Custom2" />
                <asp:BoundField DataField="Custom3" HeaderText="Custom3" />
                <asp:BoundField DataField="custom4" HeaderText="Custom4" />
                <asp:BoundField DataField="custom5" HeaderText="Custom5" />
            </Columns>
        </asp:GridView>
        <asp:ObjectDataSource ID="ErrorTrackingSource" runat="server" 
            SelectMethod="getErrors" 
            TypeName="csharpuniversity.ErrorTracking.ErrorLog" 
            onselecting="ErrorTrackingSource_Selecting" 
            onselected="ErrorTrackingSource_Selected">
            <SelectParameters>
                <asp:SessionParameter Name="DBConnString" SessionField="ErrorDB" 
                    Type="String" />
                <asp:Parameter Name="OldestFirst" Type="Boolean" />
                <asp:Parameter Name="MaxNumOfRecords" Type="Int32" />
                <asp:Parameter Name="ErrorId" Type="Int32" />
                <asp:Parameter Name="ErrMessage" Type="String" />
                <asp:Parameter Name="StartDate" Type="DateTime" />
                <asp:Parameter Name="EndDate" Type="DateTime" />
                <asp:Parameter Name="PartialMatch" Type="Boolean" />
                <asp:Parameter Name="StackTrace" Type="String" />
                <asp:Parameter Name="Location" Type="String" />
                <asp:Parameter Name="ClientIP" Type="String" />
                <asp:Parameter Name="ServerName" Type="String" />
                <asp:Parameter Name="Custom1" Type="String" />
                <asp:Parameter Name="Custom2" Type="String" />
                <asp:Parameter Name="Custom3" Type="String" />
                <asp:Parameter Name="Custom4" Type="String" />
                <asp:Parameter Name="Custom5" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </div>
</asp:Content>